//
//  TKL_ChangePassWordVC.m
//  TKL_EnPro
//
//  Created by 雅恩三河科技 on 2018/12/19.
//  Copyright © 2018年 MrZhang. All rights reserved.
//

//
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                  \\`.
//        .'//                     |                     \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
//    .'//.-"                 `-.  |  .-'                 "-.\\`.
//  .'//______.============-..   \ | /   ..-============.______\\`.
//.'______________________________\|/______________________________`.
//
//

#import "TKL_ChangePassWordVC.h"

@interface TKL_ChangePassWordVC ()<UITextFieldDelegate>
@property (strong, nonatomic) UITextField *userTF;
@property (strong, nonatomic) UITextField *passwordTF;
@property (nonatomic,strong) UIButton *loginBtn;
@property (strong, nonatomic) UILabel *fistrLab;
@property (strong, nonatomic) UILabel *secLab;
@end

@implementation TKL_ChangePassWordVC
#pragma mark - getter and setter
-(UILabel *)fistrLab
{
    if (!_fistrLab) {
        _fistrLab=[UILabel new];
        _fistrLab.x=WFCGFloatX(10);
        _fistrLab.y=WFCGFloatY(40);
        _fistrLab.width=WFCGFloatX(60);
        _fistrLab.height=WFCGFloatY(38);
        _fistrLab.font=SYSTEMFONT(15);
        _fistrLab.textColor=HEXCOLOR(@"#666666");
        _fistrLab.text=@"原密码:";
        
    }
    return _fistrLab;
}
-(UILabel *)secLab
{
    if (!_secLab) {
        _secLab=[UILabel new];
        _secLab.x=WFCGFloatX(10);
        _secLab.y=WFCGFloatY(90);
        _secLab.width=WFCGFloatX(60);;
        _secLab.height=WFCGFloatY(38);
        _secLab.font=SYSTEMFONT(15);
        _secLab.textColor=HEXCOLOR(@"#666666");
        _secLab.text=@"新密码:";
        
    }
    return _secLab;
}
-(UITextField *)userTF
{
    if (!_userTF) {
        _userTF = [[UITextField alloc]init];
        _userTF.frame = WFCGRectMake(80, 40, 280, 38);
        _userTF.placeholder = @"请输入原密码";
        _userTF.keyboardType = UIKeyboardTypePhonePad;
        _userTF.font = SYSTEMFONT(15);
        _userTF.textColor = Main_Color_Black;
        _userTF.clearButtonMode=UITextFieldViewModeWhileEditing;
        _userTF.secureTextEntry = YES;
        //        [WFFunctions WFSysddFinishButtonForText:_userTF withSelector:@selector(tapFinish) andTarget:self];
        _userTF.delegate = self;
    }
    return _userTF;
}

-(UITextField *)passwordTF
{
    if (!_passwordTF) {
        _passwordTF = [[UITextField alloc]init];
        _passwordTF.frame = WFCGRectMake(80, 90, 280, 38);
        _passwordTF.placeholder = @"请输入新密码";
        _passwordTF.font = SYSTEMFONT(15);
        _passwordTF.textColor = Main_Color_Black;
        _passwordTF.secureTextEntry = YES;
        _passwordTF.clearButtonMode=UITextFieldViewModeWhileEditing;
        _passwordTF.delegate = self;
    }
    return _passwordTF;
}
-(UIButton *)loginBtn
{
    if (!_loginBtn) {
        _loginBtn = [[UIButton alloc]init];
        _loginBtn.frame = WFCGRectMake(20, 149, 335, 45);
        [_loginBtn setBackgroundImage:[WFFunctions WFUICreateImageWithColor:RGBACOLOR(221, 221, 221, 1)] forState:UIControlStateDisabled];
        [_loginBtn addTarget:self action:@selector(loginTap:) forControlEvents:UIControlEventTouchUpInside];
        [_loginBtn setTitle:@"保存" forState:UIControlStateNormal];
        [_loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
        [_loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_loginBtn setBackgroundImage:[WFFunctions WFUICreateImageWithColor:Main_Color] forState:UIControlStateNormal];
        _loginBtn.enabled=NO;
        [WFFunctions WFUIaddbordertoView:_loginBtn radius:4 width:0 color:[UIColor clearColor]];
        _loginBtn.titleLabel.font = SYSTEMFONT(15);
    }
    return _loginBtn;
}

#pragma mark - event
-(void)loginTap:(id)sender
{
    [self.view endEditing:YES];
    if ([WFFunctions WFStrCheckEmpty:_userTF.text]) {
        [FTIndicator showErrorWithMessage:@"请输入原密码"];
        return;
    }
    if ([WFFunctions WFStrCheckEmpty:_passwordTF.text]) {
        [FTIndicator showErrorWithMessage:@"请输入新密码"];
        return;
    }
    NSMutableDictionary* para=[NSMutableDictionary new];
    //// http://101.201.171.131:8080/rest/api/user/password/update/  修改密码  newPassword=e10adc3949ba59abbe56e057f20f883e&password=b7f68bc4597ea53d837c7952b6d041c1&uuid=63e5eeec-588a-4c66-9356-ab7b4313a020
    
    [FTIndicator showProgressWithMessage:@"正在保存"];
    @WeakSelf;
    
    [para setObject:[WFFunctions md5:_passwordTF.text] forKey:@"newPassword"];
    [para setObject:[WFFunctions md5:_userTF.text] forKey:@"password"];
    [para setObject:[TKL_LoginViewModel shareInterface].infoModel.uuid forKey:@"uuid"];
    
    [[InterfaceManager shareInterface] requestAllInterface:@"http://101.201.171.131:8080/rest/api/user/password/update" para:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [FTIndicator showSuccessWithMessage:@"密码修改成功"];
        [selfp.navigationController popViewControllerAnimated:YES];
        
    }];

}
-(void)registTab:(UIButton*)sender
{

}
-(void)shwoPsw:(UIButton*)sender
{
    _passwordTF.secureTextEntry = sender.selected;
    sender.selected = !sender.selected;
}
-(void)dismissVC
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - method
-(void)initilization
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    self.navigationItem.title = @"修改密码";

    [self.view setBackgroundColor:[UIColor whiteColor]];

    [self.view addSubview:self.userTF];

    [self.view addSubview:self.passwordTF];

    [self.view addSubview:self.loginBtn];
    [self.view addSubview:self.fistrLab];
    [self.view addSubview:self.secLab];

}
-(void)viewModelBand
{
}
-(void)reloadData
{
    
}
-(void)reloadView
{
    
}
#pragma mark - life
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initilization];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */
#pragma mark - delegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if (self.userTF.text.length > 0 && self.passwordTF.text.length > 4) {
        self.loginBtn.enabled=YES;
    }else{
        self.loginBtn.enabled=NO;
    }
    return YES;
}
@end


/*
 11111111111111111111111111111111111111001111111111111111111111111
 11111111111111111111111111111111111100011111111111111111111111111
 11111111111111111111111111111111100001111111111111111111111111111
 11111111111111111111111111111110000111111111111111111111111111111
 11111111111111111111111111111000000111111111111111111111111111111
 11111111111111111111111111100000011110001100000000000000011111111
 11111111111111111100000000000000000000000000000000011111111111111
 11111111111111110111000000000000000000000000000011111111111111111
 11111111111111111111111000000000000000000000000000000000111111111
 11111111111111111110000000000000000000000000000000111111111111111
 11111111111111111100011100000000000000000000000000000111111111111
 11111111111111100000110000000000011000000000000000000011111111111
 11111111111111000000000000000100111100000000000001100000111111111
 11111111110000000000000000001110111110000000000000111000011111111
 11111111000000000000000000011111111100000000000000011110001111111
 11111110000000011111111111111111111100000000000000001111100111111
 11111111000001111111111111111111110000000000000000001111111111111
 11111111110111111111111111111100000000000000000000000111111111111
 11111111111111110000000000000000000000000000000000000111111111111
 11111111111111111100000000000000000000000000001100000111111111111
 11111111111111000000000000000000000000000000111100000111111111111
 11111111111000000000000000000000000000000001111110000111111111111
 11111111100000000000000000000000000000001111111110000111111111111
 11111110000000000000000000000000000000111111111110000111111111111
 11111100000000000000000001110000001111111111111110001111111111111
 11111000000000000000011111111111111111111111111110011111111111111
 11110000000000000001111111111111111100111111111111111111111111111
 11100000000000000011111111111111111111100001111111111111111111111
 11100000000001000111111111111111111111111000001111111111111111111
 11000000000001100111111111111111111111111110000000111111111111111
 11000000000000111011111111111100011111000011100000001111111111111
 11000000000000011111111111111111000111110000000000000011111111111
 11000000000000000011111111111111000000000000000000000000111111111
 11001000000000000000001111111110000000000000000000000000001111111
 11100110000000000001111111110000000000000000111000000000000111111
 11110110000000000000000000000000000000000111111111110000000011111
 11111110000000000000000000000000000000001111111111111100000001111
 11111110000010000000000000000001100000000111011111111110000001111
 11111111000111110000000000000111110000000000111111111110110000111
 11111110001111111100010000000001111100000111111111111111110000111
 11111110001111111111111110000000111111100000000111111111111000111
 11111111001111111111111111111000000111111111111111111111111100011
 11111111101111111111111111111110000111111111111111111111111001111
 11111111111111111111111111111110001111111111111111111111100111111
 11111111111111111111111111111111001111111111111111111111001111111
 11111111111111111111111111111111100111111111111111111111111111111
 11111111111111111111111111111111110111111111111111111111111111111
 
 
 */
